<title>Excluindo Administrador</title>

<?php
	class user
	{
		private $id;
		
		function __construct ($id)
		{
			$this->id = $id;
		}
		
		function __destruct ()
		{
			$sql="DELETE FROM administradores WHERE id=".$this->id."";
			$delete=mysql_query ($sql) or die ("Erro ao deletar administrador: ".mysql_error ());
				
			if ($delete)
			{
				echo '<script type="text/javascript">
						<!--
						alert ("Administrador excluído com sucesso!");
						window.location="index.php?page=admins/listar";
						-->
					  </script>';
			}
			else
			{
				echo '<script type="text/javascript">
						<!--
						alert ("Ocorreu um erro ao excluir o administrador!");
						window.location="index.php?page=master/listar";
						-->
					  </script>';
			}
		}
	}
	
	if ($vnivel == 1)
	{
		if (isset ($_GET['id']) && !empty ($_GET['id']))
		{
			$id = $_GET['id'];
			
			$usuario = new user ($id);
			
			$usuario->__destruct ();
		}
		else
		{
			echo '<script type="text/javascript"> history.back (); </script>';
		}
		
	}
	else
	{
		echo '<script type="text/javascript">
				window.location="index.php";
			  </script>';
	}
	
?>